package com.uzai.console.web.pyq;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.pyq.pyqcommenttemplate.PyqCommentTemplateQuery;
import com.uzai.console.dto.pyq.pyqdeviceplan.PyqDevicePlanDto;
import com.uzai.console.dto.pyq.pyqdeviceplan.PyqDevicePlanIdDto;
import com.uzai.console.dto.pyq.pyqdeviceplan.PyqDevicePlanQuery;
import com.uzai.console.entity.PyqDevicePlan;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.pyq.PyqDevicePlanService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.pyq.pyqdeviceplan.PyqDevicePlanVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设备方案
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "设备方案",tags = "个人微信|朋友圈|设备方案")
@ApiSort(31)
@RestController
public class PyqDevicePlanController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PyqDevicePlanController.class);

    @Autowired
    private PyqDevicePlanService pyqDevicePlanService;

    @ApiOperation(value = "分页查询设备方案列表", notes = "分页查询设备方案列表", response = PyqDevicePlanVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/pyqDevicePlan/findPyqDevicePlanList")
    public Object findPyqDevicePlanList(@RequestBody PyqDevicePlanQuery pyqDevicePlanQuery){
        //pyqDevicePlanQuery.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        return pyqDevicePlanService.findPyqDevicePlanList(pyqDevicePlanQuery);
    }

    @SystemLogType(model = SystemModelEnum.PyqDevicePlan, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加设备方案", notes = "添加设备方案")
    @ApiOperationSupport(order = 2)
    @PostMapping("/pyqDevicePlan/addPyqDevicePlan")
    public Object addPyqDevicePlan(@RequestBody PyqDevicePlanDto pyqDevicePlanDto){
        pyqDevicePlanService.addPyqDevicePlan(pyqDevicePlanDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqDevicePlan, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑设备方案", notes = "编辑设备方案" )
    @ApiOperationSupport(order = 3)
    @PostMapping("/pyqDevicePlan/updatePyqDevicePlan")
    public Object updatePyqDevicePlan(@RequestBody PyqDevicePlanDto pyqDevicePlanDto){
        pyqDevicePlanService.updatePyqDevicePlan(pyqDevicePlanDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqDevicePlan, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除", notes = "删除")
    @ApiOperationSupport(order = 4)
    @PostMapping("/pyqDevicePlan/deletePyqDevicePlan")
    public Object deletePyqDevicePlan(@RequestBody PyqDevicePlanIdDto pyqDevicePlanIdDto){
        pyqDevicePlanService.deletePyqDevicePlan(pyqDevicePlanIdDto);
        return true;
    }

    @ApiOperation(value = "查询设备方案详情", notes = "查询设备方案详情", response = PyqDevicePlanVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/pyqDevicePlan/findPyqDevicePlan")
    public Object findPyqDevicePlan(@RequestBody PyqDevicePlanIdDto pyqDevicePlanIdDto){
        return pyqDevicePlanService.findPyqDevicePlan(pyqDevicePlanIdDto);
    }

    @ApiOperation(value = "查询所有设备方案下拉列表", notes = "查询所有设备方案下拉列表", response = SelectKeyVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/pyqDevicePlan/findSelectList")
    public Object findSelectList(){
        PyqDevicePlanQuery pyqDevicePlanQuery = new PyqDevicePlanQuery();
        pyqDevicePlanQuery.setMerId(getLoginInfo().getMerId());
        //pyqDevicePlanQuery.setDeviceType(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        return pyqDevicePlanService.findSelectList(pyqDevicePlanQuery);
    }

}
